<?php

/**
 * AcctVoucher form base class.
 *
 * @method AcctVoucher getObject() Returns the current form's model object
 *
 * @package    tinystockmis
 * @subpackage form
 * @author     Linfeng Wu
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseAcctVoucherForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'acct_year'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctYear'), 'add_empty' => false)),
      'date'              => new sfWidgetFormDate(),
      'doc_code'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctDocumentCode'), 'add_empty' => false)),
      'doc_sn'            => new sfWidgetFormInputText(),
      'doc_summary'       => new sfWidgetFormTextarea(),
      'acct_code'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSubject'), 'add_empty' => false)),
      'amount'            => new sfWidgetFormInputText(),
      'debit_credit'      => new sfWidgetFormChoice(array('choices' => array('d' => 'd', 'c' => 'c'))),
      'doc_sum'           => new sfWidgetFormInputText(),
      'is_approved'       => new sfWidgetFormInputText(),
      'is_posted'         => new sfWidgetFormInputText(),
      'doc_opr'           => new sfWidgetFormInputText(),
      'general_ledger_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctGeneralLedger'), 'add_empty' => false)),
      'acct_set_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSet'), 'add_empty' => false)),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'acct_year'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctYear'))),
      'date'              => new sfValidatorDate(),
      'doc_code'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctDocumentCode'))),
      'doc_sn'            => new sfValidatorInteger(),
      'doc_summary'       => new sfValidatorString(array('max_length' => 500)),
      'acct_code'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSubject'))),
      'amount'            => new sfValidatorNumber(),
      'debit_credit'      => new sfValidatorChoice(array('choices' => array(0 => 'd', 1 => 'c'))),
      'doc_sum'           => new sfValidatorNumber(),
      'is_approved'       => new sfValidatorInteger(array('required' => false)),
      'is_posted'         => new sfValidatorInteger(array('required' => false)),
      'doc_opr'           => new sfValidatorString(array('max_length' => 45)),
      'general_ledger_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctGeneralLedger'))),
      'acct_set_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSet'))),
    ));

    $this->widgetSchema->setNameFormat('acct_voucher[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'AcctVoucher';
  }

}
